package ms.maplestory.boot.world;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class WorldServer {

    private int id;
    private int state;
    private String name;
    private String eventDesc;
    private int eventEXP_WSE;
    private int eventDrop_WSE;
    private boolean blockCharCreation;
    private List<ChannelServer> channelServers;
    private int adultChannel;
    private boolean recommend;
    private String recommendMsg;

    public WorldServer(int id, String name, int state, String eventDesc, int eventEXP_WSE,
                       int eventDrop_WSE, boolean blockCharCreation, int amountOfChannels, int adultChannel,
                       boolean recommend, String recommendMsg) {
        this.id = id;
        this.name = name;
        this.state = state;
        this.eventDesc = eventDesc;
        this.eventEXP_WSE = eventEXP_WSE;
        this.eventDrop_WSE = eventDrop_WSE;
        this.blockCharCreation = blockCharCreation;
        this.adultChannel = adultChannel;
        List<ChannelServer> channelServerList = new ArrayList<>();
        for (int i = 1; i <= amountOfChannels; i++) {
            channelServerList.add(new ChannelServer(name, 0, id, i, adultChannel == i));
        }
        this.channelServers = channelServerList;
        this.recommend = recommend;
        this.recommendMsg = recommendMsg;
    }

    public ChannelServer getChannelById(int id) {
        return channelServers.stream().filter(channel -> channel.getId() == id).findFirst().orElse(null);
    }
}
